package com.wxy.demo.dao;

import com.wxy.demo.entity.InterfaceInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

/**
 * <p>
 *
 * </p>
 *
 * @author e-Xiaoyuan.Wang
 * @since 2022/1/14 10:13
 */
@Repository
public interface InterfaceInfoDao extends JpaRepository<InterfaceInfo, Long> {
    InterfaceInfo findByCode(String code);

    void deleteAllByDataSourceId(Long dataSourceId);

    @Query("select sum(i.count) from InterfaceInfo i")
    Long sumRequestCount();

    InterfaceInfo findByNameAndDataSourceId(String name, Long dataSourceId);

    @Query("select count(*) from InterfaceInfo i where i.isShare = 1")
    Long countOpenApi();
}
